/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2021.
 * Description: Add tracepoint for tasklet
 * Author: shaolexi
 * Create: 2019-4-10
 */

#if !defined(_TRACE_RTOS_TASKLET_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_RTOS_TASKLET_H

#ifdef CONFIG_RTOS_TRACE_TASKLET

#undef TRACE_SYSTEM
#define TRACE_SYSTEM tasklet

#include <linux/tracepoint.h>

struct tasklet_struct;

/*
 * tasklet_entry - called immediately before calling the tasklet func
 * @t: tasklet list
 *
 * The struct tasklet_struct pointed to by @t contains various
 * information about the tasklet. When used in conjunction with the
 * tasklet_exit tracepoint, we can determine the softirq handler routine.
 */
TRACE_EVENT(tasklet_entry,

	TP_PROTO(struct tasklet_struct *t),

	TP_ARGS(t),

	TP_STRUCT__entry(
		__field(void*, func_ptr)
	),

	TP_fast_assign(
		__entry->func_ptr = t->func;
	),

	TP_printk("tasklet_func=%pS", __entry->func_ptr)
);

/*
 * tasklet_exit - called immediately after executing the tasklet func
 * @t: tasklet list
 *
 * The struct tasklet_struct pointed to by @t contains various
 * information about the tasklet. When used in conjunction with the
 * tasklet_exit tracepoint, we can determine the softirq handler routine.
 */
TRACE_EVENT(tasklet_exit,

	TP_PROTO(struct tasklet_struct *t),

	TP_ARGS(t),

	TP_STRUCT__entry(
		__field(void*, func_ptr)
	),

	TP_fast_assign(
		__entry->func_ptr = t->func;
	),

	TP_printk("tasklet_func=%pS", __entry->func_ptr)
);

/* This part must be outside protection */
#include <trace/define_trace.h>

#else
struct tasklet_struct;
void trace_tasklet_entry(struct tasklet_struct *t)
{
}
void trace_tasklet_exit(struct tasklet_struct *t)
{
}

#endif /* CONFIG_RTOS_TRACE_TASKLET */

#endif /* _TRACE_RTOS_TASKLET_H */
